{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Investor - Flow of Funds - US"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Introduction:\n",
    "\n",
    "Special thanks to: https://github.com/rgrp for sharing the dataset.\n",
    "\n",
    "### Step 1. Import the necessary libraries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/datasets/investor-flow-of-funds-us/master/data/weekly.csv). "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 3. Assign it to a variable called "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Total Equity</th>\n",
       "      <th>Domestic Equity</th>\n",
       "      <th>World Equity</th>\n",
       "      <th>Hybrid</th>\n",
       "      <th>Total Bond</th>\n",
       "      <th>Taxable Bond</th>\n",
       "      <th>Municipal Bond</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2012-12-05</td>\n",
       "      <td>-7426</td>\n",
       "      <td>-6060</td>\n",
       "      <td>-1367</td>\n",
       "      <td>-74</td>\n",
       "      <td>5317</td>\n",
       "      <td>4210</td>\n",
       "      <td>1107</td>\n",
       "      <td>-2183</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2012-12-12</td>\n",
       "      <td>-8783</td>\n",
       "      <td>-7520</td>\n",
       "      <td>-1263</td>\n",
       "      <td>123</td>\n",
       "      <td>1818</td>\n",
       "      <td>1598</td>\n",
       "      <td>219</td>\n",
       "      <td>-6842</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2012-12-19</td>\n",
       "      <td>-5496</td>\n",
       "      <td>-5470</td>\n",
       "      <td>-26</td>\n",
       "      <td>-73</td>\n",
       "      <td>103</td>\n",
       "      <td>3472</td>\n",
       "      <td>-3369</td>\n",
       "      <td>-5466</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2012-12-26</td>\n",
       "      <td>-4451</td>\n",
       "      <td>-4076</td>\n",
       "      <td>-375</td>\n",
       "      <td>550</td>\n",
       "      <td>2610</td>\n",
       "      <td>3333</td>\n",
       "      <td>-722</td>\n",
       "      <td>-1291</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2013-01-02</td>\n",
       "      <td>-11156</td>\n",
       "      <td>-9622</td>\n",
       "      <td>-1533</td>\n",
       "      <td>-158</td>\n",
       "      <td>2383</td>\n",
       "      <td>2103</td>\n",
       "      <td>280</td>\n",
       "      <td>-8931</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Date  Total Equity  Domestic Equity  World Equity  Hybrid  \\\n",
       "0  2012-12-05         -7426            -6060         -1367     -74   \n",
       "1  2012-12-12         -8783            -7520         -1263     123   \n",
       "2  2012-12-19         -5496            -5470           -26     -73   \n",
       "3  2012-12-26         -4451            -4076          -375     550   \n",
       "4  2013-01-02        -11156            -9622         -1533    -158   \n",
       "\n",
       "   Total Bond  Taxable Bond  Municipal Bond  Total  \n",
       "0        5317          4210            1107  -2183  \n",
       "1        1818          1598             219  -6842  \n",
       "2         103          3472           -3369  -5466  \n",
       "3        2610          3333            -722  -1291  \n",
       "4        2383          2103             280  -8931  "
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 4.  What is the frequency of the dataset?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# weekly data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 5. Set the column Date as the index."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Total Equity</th>\n",
       "      <th>Domestic Equity</th>\n",
       "      <th>World Equity</th>\n",
       "      <th>Hybrid</th>\n",
       "      <th>Total Bond</th>\n",
       "      <th>Taxable Bond</th>\n",
       "      <th>Municipal Bond</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2012-12-05</th>\n",
       "      <td>-7426</td>\n",
       "      <td>-6060</td>\n",
       "      <td>-1367</td>\n",
       "      <td>-74</td>\n",
       "      <td>5317</td>\n",
       "      <td>4210</td>\n",
       "      <td>1107</td>\n",
       "      <td>-2183</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012-12-12</th>\n",
       "      <td>-8783</td>\n",
       "      <td>-7520</td>\n",
       "      <td>-1263</td>\n",
       "      <td>123</td>\n",
       "      <td>1818</td>\n",
       "      <td>1598</td>\n",
       "      <td>219</td>\n",
       "      <td>-6842</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012-12-19</th>\n",
       "      <td>-5496</td>\n",
       "      <td>-5470</td>\n",
       "      <td>-26</td>\n",
       "      <td>-73</td>\n",
       "      <td>103</td>\n",
       "      <td>3472</td>\n",
       "      <td>-3369</td>\n",
       "      <td>-5466</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2012-12-26</th>\n",
       "      <td>-4451</td>\n",
       "      <td>-4076</td>\n",
       "      <td>-375</td>\n",
       "      <td>550</td>\n",
       "      <td>2610</td>\n",
       "      <td>3333</td>\n",
       "      <td>-722</td>\n",
       "      <td>-1291</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-02</th>\n",
       "      <td>-11156</td>\n",
       "      <td>-9622</td>\n",
       "      <td>-1533</td>\n",
       "      <td>-158</td>\n",
       "      <td>2383</td>\n",
       "      <td>2103</td>\n",
       "      <td>280</td>\n",
       "      <td>-8931</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Total Equity  Domestic Equity  World Equity  Hybrid  Total Bond  \\\n",
       "Date                                                                          \n",
       "2012-12-05         -7426            -6060         -1367     -74        5317   \n",
       "2012-12-12         -8783            -7520         -1263     123        1818   \n",
       "2012-12-19         -5496            -5470           -26     -73         103   \n",
       "2012-12-26         -4451            -4076          -375     550        2610   \n",
       "2013-01-02        -11156            -9622         -1533    -158        2383   \n",
       "\n",
       "            Taxable Bond  Municipal Bond  Total  \n",
       "Date                                             \n",
       "2012-12-05          4210            1107  -2183  \n",
       "2012-12-12          1598             219  -6842  \n",
       "2012-12-19          3472           -3369  -5466  \n",
       "2012-12-26          3333            -722  -1291  \n",
       "2013-01-02          2103             280  -8931  "
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 6. What is the type of the index?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index([u'2012-12-05', u'2012-12-12', u'2012-12-19', u'2012-12-26',\n",
       "       u'2013-01-02', u'2013-01-09', u'2014-04-02', u'2014-04-09',\n",
       "       u'2014-04-16', u'2014-04-23', u'2014-04-30', u'2014-05-07',\n",
       "       u'2014-05-14', u'2014-05-21', u'2014-05-28', u'2014-06-04',\n",
       "       u'2014-06-11', u'2014-06-18', u'2014-06-25', u'2014-07-02',\n",
       "       u'2014-07-09', u'2014-07-30', u'2014-08-06', u'2014-08-13',\n",
       "       u'2014-08-20', u'2014-08-27', u'2014-09-03', u'2014-09-10',\n",
       "       u'2014-11-05', u'2014-11-12', u'2014-11-19', u'2014-11-25',\n",
       "       u'2015-01-07', u'2015-01-14', u'2015-01-21', u'2015-01-28',\n",
       "       u'2015-02-04', u'2015-02-11', u'2015-03-04', u'2015-03-11',\n",
       "       u'2015-03-18', u'2015-03-25', u'2015-04-01', u'2015-04-08'],\n",
       "      dtype='object', name=u'Date')"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# it is a 'object' type"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 7. Set the index to a DatetimeIndex type"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.tseries.index.DatetimeIndex"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 8.  Change the frequency to monthly, sum the values and assign it to monthly."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Total Equity</th>\n",
       "      <th>Domestic Equity</th>\n",
       "      <th>World Equity</th>\n",
       "      <th>Hybrid</th>\n",
       "      <th>Total Bond</th>\n",
       "      <th>Taxable Bond</th>\n",
       "      <th>Municipal Bond</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2012-12-31</th>\n",
       "      <td>-26156.0</td>\n",
       "      <td>-23126.0</td>\n",
       "      <td>-3031.0</td>\n",
       "      <td>526.0</td>\n",
       "      <td>9848.0</td>\n",
       "      <td>12613.0</td>\n",
       "      <td>-2765.0</td>\n",
       "      <td>-15782.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-31</th>\n",
       "      <td>3661.0</td>\n",
       "      <td>-1627.0</td>\n",
       "      <td>5288.0</td>\n",
       "      <td>2730.0</td>\n",
       "      <td>12149.0</td>\n",
       "      <td>9414.0</td>\n",
       "      <td>2735.0</td>\n",
       "      <td>18540.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-02-28</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-03-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-04-30</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-05-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-06-30</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-07-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-08-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-09-30</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-10-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-11-30</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-12-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-01-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-02-28</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-03-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-04-30</th>\n",
       "      <td>10842.0</td>\n",
       "      <td>1048.0</td>\n",
       "      <td>9794.0</td>\n",
       "      <td>4931.0</td>\n",
       "      <td>8493.0</td>\n",
       "      <td>7193.0</td>\n",
       "      <td>1300.0</td>\n",
       "      <td>24267.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-05-31</th>\n",
       "      <td>-2203.0</td>\n",
       "      <td>-8720.0</td>\n",
       "      <td>6518.0</td>\n",
       "      <td>3172.0</td>\n",
       "      <td>13767.0</td>\n",
       "      <td>10192.0</td>\n",
       "      <td>3576.0</td>\n",
       "      <td>14736.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-06-30</th>\n",
       "      <td>2319.0</td>\n",
       "      <td>-6546.0</td>\n",
       "      <td>8865.0</td>\n",
       "      <td>4588.0</td>\n",
       "      <td>9715.0</td>\n",
       "      <td>7551.0</td>\n",
       "      <td>2163.0</td>\n",
       "      <td>16621.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-07-31</th>\n",
       "      <td>-7051.0</td>\n",
       "      <td>-11128.0</td>\n",
       "      <td>4078.0</td>\n",
       "      <td>2666.0</td>\n",
       "      <td>7506.0</td>\n",
       "      <td>7026.0</td>\n",
       "      <td>481.0</td>\n",
       "      <td>3122.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-08-31</th>\n",
       "      <td>1943.0</td>\n",
       "      <td>-5508.0</td>\n",
       "      <td>7452.0</td>\n",
       "      <td>1885.0</td>\n",
       "      <td>1897.0</td>\n",
       "      <td>-1013.0</td>\n",
       "      <td>2910.0</td>\n",
       "      <td>5723.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-09-30</th>\n",
       "      <td>-2767.0</td>\n",
       "      <td>-6596.0</td>\n",
       "      <td>3829.0</td>\n",
       "      <td>1599.0</td>\n",
       "      <td>3984.0</td>\n",
       "      <td>2479.0</td>\n",
       "      <td>1504.0</td>\n",
       "      <td>2816.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-10-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-11-30</th>\n",
       "      <td>-2753.0</td>\n",
       "      <td>-7239.0</td>\n",
       "      <td>4485.0</td>\n",
       "      <td>729.0</td>\n",
       "      <td>14528.0</td>\n",
       "      <td>11566.0</td>\n",
       "      <td>2962.0</td>\n",
       "      <td>12502.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-12-31</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-01-31</th>\n",
       "      <td>3471.0</td>\n",
       "      <td>-1164.0</td>\n",
       "      <td>4635.0</td>\n",
       "      <td>1729.0</td>\n",
       "      <td>7368.0</td>\n",
       "      <td>2762.0</td>\n",
       "      <td>4606.0</td>\n",
       "      <td>12569.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-28</th>\n",
       "      <td>5508.0</td>\n",
       "      <td>3509.0</td>\n",
       "      <td>1999.0</td>\n",
       "      <td>1752.0</td>\n",
       "      <td>9099.0</td>\n",
       "      <td>7443.0</td>\n",
       "      <td>1656.0</td>\n",
       "      <td>16359.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-31</th>\n",
       "      <td>5691.0</td>\n",
       "      <td>-8176.0</td>\n",
       "      <td>13867.0</td>\n",
       "      <td>2829.0</td>\n",
       "      <td>9138.0</td>\n",
       "      <td>7267.0</td>\n",
       "      <td>1870.0</td>\n",
       "      <td>17657.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-30</th>\n",
       "      <td>379.0</td>\n",
       "      <td>-4628.0</td>\n",
       "      <td>5007.0</td>\n",
       "      <td>970.0</td>\n",
       "      <td>423.0</td>\n",
       "      <td>514.0</td>\n",
       "      <td>-91.0</td>\n",
       "      <td>1772.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Total Equity  Domestic Equity  World Equity  Hybrid  Total Bond  \\\n",
       "Date                                                                          \n",
       "2012-12-31      -26156.0         -23126.0       -3031.0   526.0      9848.0   \n",
       "2013-01-31        3661.0          -1627.0        5288.0  2730.0     12149.0   \n",
       "2013-02-28           NaN              NaN           NaN     NaN         NaN   \n",
       "2013-03-31           NaN              NaN           NaN     NaN         NaN   \n",
       "2013-04-30           NaN              NaN           NaN     NaN         NaN   \n",
       "2013-05-31           NaN              NaN           NaN     NaN         NaN   \n",
       "2013-06-30           NaN              NaN           NaN     NaN         NaN   \n",
       "2013-07-31           NaN              NaN           NaN     NaN         NaN   \n",
       "2013-08-31           NaN              NaN           NaN     NaN         NaN   \n",
       "2013-09-30           NaN              NaN           NaN     NaN         NaN   \n",
       "2013-10-31           NaN              NaN           NaN     NaN         NaN   \n",
       "2013-11-30           NaN              NaN           NaN     NaN         NaN   \n",
       "2013-12-31           NaN              NaN           NaN     NaN         NaN   \n",
       "2014-01-31           NaN              NaN           NaN     NaN         NaN   \n",
       "2014-02-28           NaN              NaN           NaN     NaN         NaN   \n",
       "2014-03-31           NaN              NaN           NaN     NaN         NaN   \n",
       "2014-04-30       10842.0           1048.0        9794.0  4931.0      8493.0   \n",
       "2014-05-31       -2203.0          -8720.0        6518.0  3172.0     13767.0   \n",
       "2014-06-30        2319.0          -6546.0        8865.0  4588.0      9715.0   \n",
       "2014-07-31       -7051.0         -11128.0        4078.0  2666.0      7506.0   \n",
       "2014-08-31        1943.0          -5508.0        7452.0  1885.0      1897.0   \n",
       "2014-09-30       -2767.0          -6596.0        3829.0  1599.0      3984.0   \n",
       "2014-10-31           NaN              NaN           NaN     NaN         NaN   \n",
       "2014-11-30       -2753.0          -7239.0        4485.0   729.0     14528.0   \n",
       "2014-12-31           NaN              NaN           NaN     NaN         NaN   \n",
       "2015-01-31        3471.0          -1164.0        4635.0  1729.0      7368.0   \n",
       "2015-02-28        5508.0           3509.0        1999.0  1752.0      9099.0   \n",
       "2015-03-31        5691.0          -8176.0       13867.0  2829.0      9138.0   \n",
       "2015-04-30         379.0          -4628.0        5007.0   970.0       423.0   \n",
       "\n",
       "            Taxable Bond  Municipal Bond    Total  \n",
       "Date                                               \n",
       "2012-12-31       12613.0         -2765.0 -15782.0  \n",
       "2013-01-31        9414.0          2735.0  18540.0  \n",
       "2013-02-28           NaN             NaN      NaN  \n",
       "2013-03-31           NaN             NaN      NaN  \n",
       "2013-04-30           NaN             NaN      NaN  \n",
       "2013-05-31           NaN             NaN      NaN  \n",
       "2013-06-30           NaN             NaN      NaN  \n",
       "2013-07-31           NaN             NaN      NaN  \n",
       "2013-08-31           NaN             NaN      NaN  \n",
       "2013-09-30           NaN             NaN      NaN  \n",
       "2013-10-31           NaN             NaN      NaN  \n",
       "2013-11-30           NaN             NaN      NaN  \n",
       "2013-12-31           NaN             NaN      NaN  \n",
       "2014-01-31           NaN             NaN      NaN  \n",
       "2014-02-28           NaN             NaN      NaN  \n",
       "2014-03-31           NaN             NaN      NaN  \n",
       "2014-04-30        7193.0          1300.0  24267.0  \n",
       "2014-05-31       10192.0          3576.0  14736.0  \n",
       "2014-06-30        7551.0          2163.0  16621.0  \n",
       "2014-07-31        7026.0           481.0   3122.0  \n",
       "2014-08-31       -1013.0          2910.0   5723.0  \n",
       "2014-09-30        2479.0          1504.0   2816.0  \n",
       "2014-10-31           NaN             NaN      NaN  \n",
       "2014-11-30       11566.0          2962.0  12502.0  \n",
       "2014-12-31           NaN             NaN      NaN  \n",
       "2015-01-31        2762.0          4606.0  12569.0  \n",
       "2015-02-28        7443.0          1656.0  16359.0  \n",
       "2015-03-31        7267.0          1870.0  17657.0  \n",
       "2015-04-30         514.0           -91.0   1772.0  "
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 9. You will notice that it filled the dataFrame with months that don't have any data with NaN. Let's drop these rows."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Total Equity</th>\n",
       "      <th>Domestic Equity</th>\n",
       "      <th>World Equity</th>\n",
       "      <th>Hybrid</th>\n",
       "      <th>Total Bond</th>\n",
       "      <th>Taxable Bond</th>\n",
       "      <th>Municipal Bond</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2012-12-31</th>\n",
       "      <td>-26156.0</td>\n",
       "      <td>-23126.0</td>\n",
       "      <td>-3031.0</td>\n",
       "      <td>526.0</td>\n",
       "      <td>9848.0</td>\n",
       "      <td>12613.0</td>\n",
       "      <td>-2765.0</td>\n",
       "      <td>-15782.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-31</th>\n",
       "      <td>3661.0</td>\n",
       "      <td>-1627.0</td>\n",
       "      <td>5288.0</td>\n",
       "      <td>2730.0</td>\n",
       "      <td>12149.0</td>\n",
       "      <td>9414.0</td>\n",
       "      <td>2735.0</td>\n",
       "      <td>18540.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-04-30</th>\n",
       "      <td>10842.0</td>\n",
       "      <td>1048.0</td>\n",
       "      <td>9794.0</td>\n",
       "      <td>4931.0</td>\n",
       "      <td>8493.0</td>\n",
       "      <td>7193.0</td>\n",
       "      <td>1300.0</td>\n",
       "      <td>24267.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-05-31</th>\n",
       "      <td>-2203.0</td>\n",
       "      <td>-8720.0</td>\n",
       "      <td>6518.0</td>\n",
       "      <td>3172.0</td>\n",
       "      <td>13767.0</td>\n",
       "      <td>10192.0</td>\n",
       "      <td>3576.0</td>\n",
       "      <td>14736.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-06-30</th>\n",
       "      <td>2319.0</td>\n",
       "      <td>-6546.0</td>\n",
       "      <td>8865.0</td>\n",
       "      <td>4588.0</td>\n",
       "      <td>9715.0</td>\n",
       "      <td>7551.0</td>\n",
       "      <td>2163.0</td>\n",
       "      <td>16621.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-07-31</th>\n",
       "      <td>-7051.0</td>\n",
       "      <td>-11128.0</td>\n",
       "      <td>4078.0</td>\n",
       "      <td>2666.0</td>\n",
       "      <td>7506.0</td>\n",
       "      <td>7026.0</td>\n",
       "      <td>481.0</td>\n",
       "      <td>3122.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-08-31</th>\n",
       "      <td>1943.0</td>\n",
       "      <td>-5508.0</td>\n",
       "      <td>7452.0</td>\n",
       "      <td>1885.0</td>\n",
       "      <td>1897.0</td>\n",
       "      <td>-1013.0</td>\n",
       "      <td>2910.0</td>\n",
       "      <td>5723.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-09-30</th>\n",
       "      <td>-2767.0</td>\n",
       "      <td>-6596.0</td>\n",
       "      <td>3829.0</td>\n",
       "      <td>1599.0</td>\n",
       "      <td>3984.0</td>\n",
       "      <td>2479.0</td>\n",
       "      <td>1504.0</td>\n",
       "      <td>2816.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-11-30</th>\n",
       "      <td>-2753.0</td>\n",
       "      <td>-7239.0</td>\n",
       "      <td>4485.0</td>\n",
       "      <td>729.0</td>\n",
       "      <td>14528.0</td>\n",
       "      <td>11566.0</td>\n",
       "      <td>2962.0</td>\n",
       "      <td>12502.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-01-31</th>\n",
       "      <td>3471.0</td>\n",
       "      <td>-1164.0</td>\n",
       "      <td>4635.0</td>\n",
       "      <td>1729.0</td>\n",
       "      <td>7368.0</td>\n",
       "      <td>2762.0</td>\n",
       "      <td>4606.0</td>\n",
       "      <td>12569.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-02-28</th>\n",
       "      <td>5508.0</td>\n",
       "      <td>3509.0</td>\n",
       "      <td>1999.0</td>\n",
       "      <td>1752.0</td>\n",
       "      <td>9099.0</td>\n",
       "      <td>7443.0</td>\n",
       "      <td>1656.0</td>\n",
       "      <td>16359.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-31</th>\n",
       "      <td>5691.0</td>\n",
       "      <td>-8176.0</td>\n",
       "      <td>13867.0</td>\n",
       "      <td>2829.0</td>\n",
       "      <td>9138.0</td>\n",
       "      <td>7267.0</td>\n",
       "      <td>1870.0</td>\n",
       "      <td>17657.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-30</th>\n",
       "      <td>379.0</td>\n",
       "      <td>-4628.0</td>\n",
       "      <td>5007.0</td>\n",
       "      <td>970.0</td>\n",
       "      <td>423.0</td>\n",
       "      <td>514.0</td>\n",
       "      <td>-91.0</td>\n",
       "      <td>1772.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Total Equity  Domestic Equity  World Equity  Hybrid  Total Bond  \\\n",
       "Date                                                                          \n",
       "2012-12-31      -26156.0         -23126.0       -3031.0   526.0      9848.0   \n",
       "2013-01-31        3661.0          -1627.0        5288.0  2730.0     12149.0   \n",
       "2014-04-30       10842.0           1048.0        9794.0  4931.0      8493.0   \n",
       "2014-05-31       -2203.0          -8720.0        6518.0  3172.0     13767.0   \n",
       "2014-06-30        2319.0          -6546.0        8865.0  4588.0      9715.0   \n",
       "2014-07-31       -7051.0         -11128.0        4078.0  2666.0      7506.0   \n",
       "2014-08-31        1943.0          -5508.0        7452.0  1885.0      1897.0   \n",
       "2014-09-30       -2767.0          -6596.0        3829.0  1599.0      3984.0   \n",
       "2014-11-30       -2753.0          -7239.0        4485.0   729.0     14528.0   \n",
       "2015-01-31        3471.0          -1164.0        4635.0  1729.0      7368.0   \n",
       "2015-02-28        5508.0           3509.0        1999.0  1752.0      9099.0   \n",
       "2015-03-31        5691.0          -8176.0       13867.0  2829.0      9138.0   \n",
       "2015-04-30         379.0          -4628.0        5007.0   970.0       423.0   \n",
       "\n",
       "            Taxable Bond  Municipal Bond    Total  \n",
       "Date                                               \n",
       "2012-12-31       12613.0         -2765.0 -15782.0  \n",
       "2013-01-31        9414.0          2735.0  18540.0  \n",
       "2014-04-30        7193.0          1300.0  24267.0  \n",
       "2014-05-31       10192.0          3576.0  14736.0  \n",
       "2014-06-30        7551.0          2163.0  16621.0  \n",
       "2014-07-31        7026.0           481.0   3122.0  \n",
       "2014-08-31       -1013.0          2910.0   5723.0  \n",
       "2014-09-30        2479.0          1504.0   2816.0  \n",
       "2014-11-30       11566.0          2962.0  12502.0  \n",
       "2015-01-31        2762.0          4606.0  12569.0  \n",
       "2015-02-28        7443.0          1656.0  16359.0  \n",
       "2015-03-31        7267.0          1870.0  17657.0  \n",
       "2015-04-30         514.0           -91.0   1772.0  "
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Step 10. Good, now we have the monthly data. Now change the frequency to year."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Total Equity</th>\n",
       "      <th>Domestic Equity</th>\n",
       "      <th>World Equity</th>\n",
       "      <th>Hybrid</th>\n",
       "      <th>Total Bond</th>\n",
       "      <th>Taxable Bond</th>\n",
       "      <th>Municipal Bond</th>\n",
       "      <th>Total</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2012-01-01</th>\n",
       "      <td>-26156.0</td>\n",
       "      <td>-23126.0</td>\n",
       "      <td>-3031.0</td>\n",
       "      <td>526.0</td>\n",
       "      <td>9848.0</td>\n",
       "      <td>12613.0</td>\n",
       "      <td>-2765.0</td>\n",
       "      <td>-15782.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2013-01-01</th>\n",
       "      <td>3661.0</td>\n",
       "      <td>-1627.0</td>\n",
       "      <td>5288.0</td>\n",
       "      <td>2730.0</td>\n",
       "      <td>12149.0</td>\n",
       "      <td>9414.0</td>\n",
       "      <td>2735.0</td>\n",
       "      <td>18540.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2014-01-01</th>\n",
       "      <td>330.0</td>\n",
       "      <td>-44689.0</td>\n",
       "      <td>45021.0</td>\n",
       "      <td>19570.0</td>\n",
       "      <td>59890.0</td>\n",
       "      <td>44994.0</td>\n",
       "      <td>14896.0</td>\n",
       "      <td>79787.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-01-01</th>\n",
       "      <td>15049.0</td>\n",
       "      <td>-10459.0</td>\n",
       "      <td>25508.0</td>\n",
       "      <td>7280.0</td>\n",
       "      <td>26028.0</td>\n",
       "      <td>17986.0</td>\n",
       "      <td>8041.0</td>\n",
       "      <td>48357.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            Total Equity  Domestic Equity  World Equity   Hybrid  Total Bond  \\\n",
       "Date                                                                           \n",
       "2012-01-01      -26156.0         -23126.0       -3031.0    526.0      9848.0   \n",
       "2013-01-01        3661.0          -1627.0        5288.0   2730.0     12149.0   \n",
       "2014-01-01         330.0         -44689.0       45021.0  19570.0     59890.0   \n",
       "2015-01-01       15049.0         -10459.0       25508.0   7280.0     26028.0   \n",
       "\n",
       "            Taxable Bond  Municipal Bond    Total  \n",
       "Date                                               \n",
       "2012-01-01       12613.0         -2765.0 -15782.0  \n",
       "2013-01-01        9414.0          2735.0  18540.0  \n",
       "2014-01-01       44994.0         14896.0  79787.0  \n",
       "2015-01-01       17986.0          8041.0  48357.0  "
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### BONUS: Create your own question and answer it."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
